<style>
    body {
        background-color: #ffffff;
    }

    .xm-select-size {
        width: 200px;
        float: left;
    }
</style>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">服务次数</label>
        <div class="layui-input-block">
            <input type="number" name="number" lay-verify="required" lay-reqtext="服务次数不能为空" placeholder="请输入服务次数"
                   value=""
                   class="layui-input">
            <tip></tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">原价</label>
        <div class="layui-input-block">
            <input type="number" name="old_price" lay-verify="required" lay-reqtext="服务原价不能为空" placeholder="请输入服务原价"
                   value=""
                   class="layui-input">
            <tip></tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">现价</label>
        <div class="layui-input-block">
            <input type="number" name="price" lay-verify="required" lay-reqtext="服务现价不能为空" placeholder="请输入服务现价"
                   value=""
                   class="layui-input">
            <tip></tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">服务项目</label>
        <div class="layui-input-block">
            <div id="service"></div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
<script type="text/javascript">
    layui.config({
        base: '/static/extends/'
    }).extend({
        xmSelect: 'xmSelect/xm-select'
    });
    layui.use(['form', 'xmSelect', "upload", "element", "transfer"], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$,
            xmSelect = layui.xmSelect,
            upload = layui.upload,
            element = layui.element,
            transfer = layui.transfer;

        transfer.render({
            elem: '#service'  //绑定元素
            , data: {$transferData|raw}
            , id: 'service' //定义索引
            ,title :["可选项目","已选项目"]
            , parseData: function (res) {
                return {
                    "value": res.id //数据值
                    , "title": res.title //数据标题
                    , "disabled": res.disabled  //是否禁用
                    , "checked": res.checked //是否选中
                }
            }
        });
        //监听提交
        form.on('submit(saveBtn)', function (data) {
            data.field['service'] = transfer.getData('service');
            hadmin.http("{:url('save')}", data.field).then(res => {
                if (res.code == "{$result.normal}") {
                    hadmin.father_reload();
                }
            })

            return false;
        });


    });
</script>
</body>
</html>